package com.ruoyi.merchant.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.merchant.annotation.DictFilter;
import com.ruoyi.merchant.domain.WhiteList;
import com.ruoyi.merchant.service.IWhiteListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 白名单Controller
 * 
 * @author ruoyi
 * @date 2024-09-03
 */
@Controller
@RequestMapping("/white")
public class WhiteListController extends BaseController
{
    @Autowired
    private IWhiteListService whiteListService;


    /**
     * 查询白名单列表
     */
    @GetMapping("/list")
    @DictFilter(dataType = "page")
    @ResponseBody
    public TableDataInfo list(WhiteList whiteList)
    {
        startPage();
        List<WhiteList> list = whiteListService.selectWhiteListList(whiteList);
        return getDataTable(list);
    }



    /**
     * 新增保存白名单
     */
    @Log(title = "白名单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WhiteList whiteList)
    {
        return toAjax(whiteListService.insertWhiteList(whiteList));
    }

    /**
     * 修改保存白名单
     */
    @Log(title = "白名单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WhiteList whiteList)
    {
        return toAjax(whiteListService.updateWhiteList(whiteList));
    }

    /**
     * 删除白名单
     */
    @Log(title = "白名单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(whiteListService.deleteWhiteListByIds(ids));
    }
}
